package com.heima.article.task;

import com.heima.article.service.IApArticleService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

@Component
@Slf4j
public class HotArticleTask {

    @Autowired
    private IApArticleService articleService;

//    @Scheduled(cron = "0/10 * * * * ?")  //为了模拟效果，这里先设置成每隔10秒

    @XxlJob("computeHotArticleHandler")
    public ReturnT<String> computeHotArticle(String param){
        log.info("开始执行每日文章分值计算任务......");

        try {
            articleService.computeHotArticle();
            return ReturnT.SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            return ReturnT.FAIL;
        }
    }
}
